<template>
<el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
                <el-select v-model="dataForm.islandId" placeholder="请选择区域" clearable>
                  <el-option v-for="item in scenicOptions" :key="item.id" :label="item.scenicName" :value="item.scenicName">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <ren-select v-model="dataForm.merchantCategory" dict-type="MerchantCategory" placeholder="请选择商户类型" style="width:100%"></ren-select>
            </el-form-item>
            <el-form-item>
                <el-select v-model="dataForm.orderStatus" placeholder="请选择订单状态" clearable>
                    <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.orderCode" placeholder="订单编号" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.productName" placeholder="商品名称" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.productType" placeholder="商品类型" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.guestName" placeholder="联系人" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.guestPhone" placeholder="联系方式" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="getDataList()">{{ $t("query") }}</el-button>
            </el-form-item>
            <!-- <el-form-item>
                <el-button type="primary" @click="exportHandle()">导出</el-button>
            </el-form-item> -->
        </el-form>
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
            <el-table-column prop="orderCode" label="订单编号" header-align="center" min-width="150" align="center"></el-table-column>
            <el-table-column prop="productName" label="商品名称" header-align="center" min-width="150" align="center"></el-table-column>
            <el-table-column prop="productType" label="商品类型" header-align="center" min-width="150" align="center">
            </el-table-column>
            <el-table-column prop="num" label="数量" header-align="center" min-width="150" align="center">
            </el-table-column>
            <el-table-column prop="guestName" label="联系人" header-align="center" min-width="150" align="center"></el-table-column>
            <el-table-column prop="guestPhone" label="联系电话" header-align="center" min-width="150" align="center"></el-table-column>
            <el-table-column prop="orderAmount" label="总价" header-align="center" min-width="150" align="center"></el-table-column>
            <el-table-column prop="orderStatus" label="订单状态" header-align="center" min-width="150" align="center">
                <template slot-scope="scope">
                    <span :style="{'background':statusColor[scope.row.orderStatus]}" class="status">
                        {{statusType[scope.row.orderStatus]}}
                    </span>
                </template>
            </el-table-column>
            <el-table-column prop="orderTime" label="下单时间" header-align="center" align="center" min-width="150">
            </el-table-column>
            <el-table-column prop="islandName" label="所属区域" header-align="center" min-width="150" align="center">
            </el-table-column>
            <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="lookDetail(scope.row.id)">详情</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- /详情-->
        <look-detail v-if="lookDetailVisible" ref="lookDetail" @refreshDataList="getDataList"></look-detail>
    </div>
</el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import lookDetail from "./lookDetail";
export default {
    mixins: [mixinViewModule],
    data() {
        return {
            mixinViewModuleOptions: {
                getDataListURL: "/scenic/merchant/order/page",
                getDataListIsPage: true,
                exportURL: "/scenic/fishermanorder/export",
                deleteURL: "/scenic/merchant/order",
                deleteIsBatch: true,
            },
            scenicOptions: [],
            dataForm: {
                merchantCategory: '',
                islandId: '',
                orderStatus: '',
                productName: '',
                productType: '',
                guestName: '',
                guestPhone: '',
                orderTimeStart: '',
                merchantName: '',
                merchantId: '',
                orderTimeEnd: '',
                orderCode: '',
                userId: this.$store.state.user.superAdmin == 1 ? '' : this.$store.state.user.id
            },
            status: [{
                    label: "审核未通过",
                    value: 4,
                },
                {
                    label: "审核通过",
                    value: 1,
                },
                {
                    label: "待审核",
                    value: 2,
                },
            ],
            statusColor: {
                '0': '#FF4141',
                '1': '#409EFF',
                '2': '#CCCCCC',
                '3': '#FF9C3D',
                '4': '#AAAAAA'
            },
            statusType: {
                '0': '待支付',
                '1': '待使用',
                '2': '已使用',
                '3': '退票中',
                '4': '已退票'
            }, //
        };
    },
    components: {
        lookDetail
    },
    created() {
        this.getScenicOptions();
    },
    methods: {
         //岛屿
        getScenicOptions() {
            this.$http
                .get("scenic/isscenic/selectScenicList", {})
                .then(({
                    data: res
                }) => {
                    if (res.msg == "success") {
                        this.scenicOptions = res.data;
                    }
                });
        },
    },
};
</script>

<style scoped>
.status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #fff
}
</style>
